#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
using namespace std;
const int num = 8;

int find(int a[], int key, int n)
{
    for (int i = 0; i < n; ++i)
    {
        if (a[i] == key)
        {
            return i + 1;
        }
    }
    return 0;
}

void copy(int a[], int b[], int n)
{
    for (int i = 0; i < n; ++i)
    {
        b[i] = a[i];
    }
}
void reverse(int a[], int n)
{
    int temp;
    int i, j = n - 1, m = (n - 1) / 2;
    for (i = 0; i <= m; ++i)
    {
        j = n - 1 - i;
        temp = a[i];
        a[i] = a[j];
        a[j] = temp;
    }
}
int main()
{
    int a[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
    cout << find(a, 4, num) << endl;
    int b[num];
    copy(a, b, num);
    reverse(a, num);
    cout << find(a, 4, num) << endl;
    for (int i = 0; i < num; ++i)
    {
        cout << a[i] << " ";
    }
    cout << endl;
    for (int i = 0; i < num; ++i)
    {
        cout << b[i] << " ";
    }
    cout << endl;
    return 0;
}